#include "ros/ros.h"
#include "std_msgs/String.h"

int main(int argc, char *argv[])
{
    setlocale(LC_ALL, "");
    ros::init(argc, argv, "pub");
    ros::NodeHandle nh;
    ros::Publisher pub = nh.advertise<std_msgs::String>("fang", 10);
    ros::Rate rate(1);
    while(ros::ok) {
        std_msgs::String msg;
        msg.data = "Hello world!";
        pub.publish(msg);
        ROS_INFO("发送的消息：%s", msg.data.c_str());
        rate.sleep();
        ros::spinOnce();
    }
    return 0;
}
